package com.example.leo.mycharmingstudent.customview;

import android.animation.ObjectAnimator;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import com.example.leo.mycharmingstudent.R;

public class CustomViewActivity extends AppCompatActivity {

    private ProgressBarView mProgressBarView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_custom_view);

        mProgressBarView = findViewById(R.id.pbv_activity_custom_view);
        mProgressBarView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                /*int progress = mProgressBarView.getProgress() + 2;
                mProgressBarView.setProgress(progress);*/
                /*
                第二个参数设置为progress1，
                那么属性动画就会不停地调用第一个参数的setProgress1这个方法
                 */
                ObjectAnimator.ofInt(mProgressBarView, "progress1", 0, 100)
                        .setDuration(3000)
                        .start();
            }
        });
    }
}
